package com.quantgroup.data.entity;

import lombok.Data;

/**
 * @author osmondy
 * @create 2021/10/3 15:07
 */
@Data
public class Result {
    /**
     * 响应代码
     */
    private int code;

    /**
     * 响应消息
     */
    private String message;

    /**
     * 响应结果
     */
    private Object result;


    /**
     * 成功
     *
     * @param data
     * @return
     */
    public static Result success(Object data) {
        Result rb = new Result();
        rb.setCode(200);
        rb.setMessage("success!");
        rb.setResult(data);
        return rb;
    }

    /**
     * 失败
     */
    public static Result error(int code, String message) {
        Result rb = new Result();
        rb.setCode(code);
        rb.setMessage(message);
        rb.setResult(null);
        return rb;
    }

    /**
     * 失败
     */
    public static Result error(String message) {
        Result rb = new Result();
        rb.setCode(500);
        rb.setMessage(message);
        rb.setResult(null);
        return rb;
    }

}
